package org.example.petadoption.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.example.petadoption.entity.Product;
import org.example.petadoption.entity.ProductInfoDTO;

import java.util.List;

/**
 * <p>
 * 商品表 Mapper 接口
 * </p>
 *
 * @author PetAdoption
 * @since 2025-10-20
 */
public interface ProductMapper extends BaseMapper<Product> {

    @Select("SELECT " +
            "p.name AS productName, " +
            "m.name AS merchantName, " +
            "p.price AS price, " +
            "CASE p.status " +
            "WHEN 0 THEN '待审核' " +
            "WHEN 1 THEN '已上架' " +
            "WHEN 2 THEN '已下架' " +
            "ELSE '未知状态' END AS status " +
            "FROM product p " +
            "LEFT JOIN merchant m ON p.merchant_id = m.id")
    List<ProductInfoDTO> getAllProductInfo();

}
